<template>
  <div>
      <van-field label="用户名" placeholder="请输入" v-model="name"/>
      <van-field label="密码" placeholder="请输入" v-model="password"/>
      <van-button @click="login"> 登陆 </van-button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            name:'',
            password:''
        }
    },
    methods:{
        login(){
            axios.get('http://127.0.0.1:5000/login?name='+this.name+'&password='+this.password).then(res=>{
                alert(res.data.msg)
                localStorage.setItem('userid',res.data.userid)
                localStorage.setItem('username',res.data.username)
                localStorage.setItem('list',JSON.stringify(res.data.list))
                this.$router.push("/perindex")
            })
        }
    }

}
</script>

<style>

</style>